{# SPDX-License-Identifier: Apache-2.0 -#}

{% extends "admin/base.html" %}

{% block title %}Confirm Project Name Prohibition for {{ prohibited_project_names.project }}{% endblock %}

{% block breadcrumb %}
  <li class="breadcrumb-item"><a href="{{ request.route_path('admin.prohibited_project_names.list') }}">Prohibit</a></li>
  <li class="breadcrumb-item active">Confirm for {{ prohibited_project_names.project }}</li>
{% endblock %}

{% block content %}
<div class="row justify-content-md-center">
  <div class="col-md-8">
    <div class="card card-primary">
      <div class="card-body">
        {% if existing.project %}
        <div>
          Prohibiting {{ prohibited_project_names.project }} will irreversibly delete
          the <a href="{{ request.route_path('admin.project.detail', project_name=existing.project.normalized_name) }}">{{ existing.project.name }}</a>
          project along with the following
          <a href="{{ request.route_path('admin.project.releases', project_name=existing.project.normalized_name) }}">{{ existing.releases|length() }} releases</a>:

          <ul>
            {% for date, releases in existing.releases_by_date|dictsort(reverse=True) %}
            <li>
              {{ date }} -
              {% for release in releases %}
              <a href="{{ request.route_path('admin.project.release', project_name=release.project.normalized_name, version=release.version) }}">{{ release.version }}</a>{% if not loop.last %}, {% endif %}
              {% endfor %}
            </li>
            {% endfor %}
          </ul>

          This project has {{ existing.roles|length }} users able to
          access it, listed below:

          <ul>
            {% for role in existing.roles %}
            <li>
              <a href="{{ request.route_path('admin.user.detail', username=role.user.username) }}">
                {{ role.user.username }}
              </a>
              <em>({{ role.role_name }})</em>
            </li>
            {% endfor %}
          </ul>
        </div>
        {% endif %}

        <p>
          Are you sure you want to prohibit
          <code id="project-name">{{ prohibited_project_names.project }}</code>
          <button type="button" class="copy-text" data-copy-text="{{ prohibited_project_names.project }}">
            <i class="fa fa-copy" aria-hidden="true"></i>
          </button>
          ?
        </p>

        <form action="{{ request.current_route_path() }}" method="POST">
          <input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
          <input name="project" type="hidden" value="{{ prohibited_project_names.project }}">
          <input name="comment" type="Hidden" value="{{ prohibited_project_names.comment }}">

          <div class="form-group col-sm-8">
            <input name="confirm" class="form-control" type="text" placeholder="Enter project name to confirm" autocomplete="off" autocorrect="off" autocapitalize="off">
          </div>

          <div class="form-group col-sm-4">
            <button type="submit" class="btn btn-danger">Confirm</button>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
{% endblock %}
